<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>后台管理</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="icon" href="javascript:;">
  <link rel="stylesheet" href="../../resource/layui/css/layui.css"  media="all">
  <link rel="stylesheet" href="../../resource/myResource/css/no_read_item.css">
  <link rel="stylesheet" href="../../resource/myResource/css/personal/personal_detail.css">
</head>
<style>
</style>
<body>
    <form class="layui-form" action="" style="margin-top:30px;width: 75%;">
        <div class="layui-form-item">
            <label class="layui-form-label">旧密码：</label>
            <div class="layui-input-block">
              <input type="password" name="oldPassword" placeholder="请输入旧密码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">新密码：</label>
            <div class="layui-input-block">
              <input type="password" name="password" placeholder="请输入新密码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">确认密码：</label>
            <div class="layui-input-block">
              <input type="password" name="surePassword" placeholder="请再次输入密码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label">验证码：</label>
              <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input">
              </div>
              <div class="layui-input-inline">
                <img id="verifyCode" onclick="reloadCode()">
              </div>
            </div>
        </div>
        <div style="margin-top:50px;margin-bottom: 25px">
            <!-- <button type="button" class="layui-btn layui-btn-normal "style="margin-left:80%" onclick="submit()">提交</button> -->
            <button type="button" class="layui-btn layui-btn-normal "style="margin-left:80%; margin-top:60px" onclick="submitBtn()">提交</button>
                            
        </div>

    </form>
    <script src="../../resource/jquery/dist/jquery.js"></script>
    <script src="../../resource/layui/layui.js" charset="utf-8"></script>
    <script src="../../resource/myResource/js/base.js"></script>
    <script src="../../resource/md5/md5.js"></script>
    <script src="../..//resource/myResource/js/repaorjs/repair_no_read_item.js"></script>
    <script type="text/javascript">
        $("#verifyCode").attr("src",head+"/verify/getVerifyCode")
        function reloadCode(){
          $("#verifyCode").attr("src",head+"/verify/getVerifyCode?id="+Math.random()); 
        }
        layui.use(['form', 'layedit', 'laydate'], function(){});
        //获得id渲染页面
        // alert(GetQueryString("id"));

        // 调用方法： 
        // alert(GetQueryString("id"));
        
       
    </script>
    
    <script>
        function submitBtn(){
          // debugger;
          var oldPassword = $(" input[ name='oldPassword' ] ").val();
          var password = $(" input[ name='password' ] ").val();
          var surePassword = $(" input[ name='surePassword' ] ").val();
          var id = getId();
          if(surePassword != password){
            layer.msg("两次输入的密码不一致");
            return;
          }
          oldPassword = hex_md5(oldPassword);
          password = hex_md5(password);
          // for(i=0;i<100;i++){
          //     console.info(hex_md5(password));
          // }
          
          // alert(oldPassword);
          // alert(password);
          $.ajax({
            url:head+"/user/passwordChange",
            data:{"id":id,"type":1,"password":password,"oldPassword":oldPassword},
            type:"post",
            dataType:"json",
            success:function(redata){
              if(redata.code != 0){
                layer.msg(redata.msg);
              }else{
                setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
                  window.parent.parent.location.reload();//页面刷新
                },1500);
                layer.msg("密码修改成功，即将跳转登录页面");
              }
            }
          });
         }
    </script>
</body> 
</html>